From: Shinjiman Date: Sat, 23 May 2009 19:26:05 +0000 (+0000) Subject: * (bug 18698) Renaming non entry point maintenance scripts from .inc.php to .inc X-Git-Tag: 1.31.0-rc.0~41672 X-Git-Url: http://git.cyclocoop.org/%7D%7Cconcat%7B?a=commitdiff_plain;h=54396bab19a878022ac3d43631a2d0d397b8984e;p=lhc%2Fweb%2Fwiklou.git * (bug 18698) Renaming non entry point maintenance scripts from .inc.php to .inc patch by Karun Dambiec --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index df25b9cb21..b11fca0b23 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -150,6 +150,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Fix array logic in Sanitizer::removeHTMLtags so that it doesn't strip good tags that were redundantly defined. * (bug 14118) SpecialPage::getTitleFor does not return a localised name +* (bug 18698) Renaming non entry point maintenance scripts from .inc.php to .inc == API changes in 1.16 == diff --git a/docs/php-memcached/ChangeLog b/docs/php-memcached/ChangeLog index 86792f607e..553aaa1983 100644 --- a/docs/php-memcached/ChangeLog +++ b/docs/php-memcached/ChangeLog @@ -1,45 +1,28 @@ -Release 1.0.10 --------------- -* bug fix: changes hashing function to crc32, sprintf %u -* feature: optional compression +09 Oct 2003: + 1455 UTC: + Released version 0.1.2 + Fixed bug in get_multi; when debugging was enabled but no keys were fetched, + script execution would halt (uninitialized $val) -Release 1.0.9 -------------- -* protocol parsing bug +08 Oct 2003: + 1848 UTC: + Released version 0.1.1 -Release 1.0.8 -------------- -* whitespace/punctuation/wording cleanups + 1825 UTC: + Fixed bug in memcached::memcached; was attempting to initialize + memcached::_dead_sock (function) instead of memcached::_dead_hosts + (oops!) -Release 1.0.7 -------------- -* added 3 functions which handle error reporting - error() - returns error number of last error generated, else returns 0 - error_string() - returns a string description of error number retuned - error_clear() - clears the last error number and error string -* removed call to preg_match() in _loaditems() -* only non-scalar values are serialize() before being - sent to the server -* added the optional timestamp argument for delete() - read Documentation file for details -* PHPDocs/PEAR style comments added -* abstract debugging (Brion Vibber ) - -Release 1.0.6 -------------- -* removed all array_push() calls -* applied patch provided by Stuart Herbert - corrects possible endless loop. Available at - http://bugs.gentoo.org/show_bug.cgi?id=25385 -* fixed problem with storing large binary files -* added more error checking, specifically on all socket functions -* added support for the INCR and DECR commands - which increment or decrement a value stored in MemCached -* Documentation removed from source and is now available - in the file Documentation + 1812 UTC: + Fixed memcached::enable_compression; + thanks to Justin Matlock for pointing it out + +07 Oct 2003: + 1635 UTC: + Fixed call to memcached::_dead_sock in memcached::delete + Added documentation for class variable $_buckets + +06 Oct 2003: + 2039 UTC: + Initial release of memcached-client-php; version 0.1 -Release 1.0.4 -------------- -* initial release, version numbers kept - in sync with MemCached version -* capable of storing any datatype in MemCached diff --git a/docs/php-memcached/README b/docs/php-memcached/README new file mode 100644 index 0000000000..07812dda22 --- /dev/null +++ b/docs/php-memcached/README @@ -0,0 +1 @@ +HTML documentation is under http://phpca.cytherianage.net/memcached/doc/ diff --git a/maintenance/deleteOrphanedRevisions.inc b/maintenance/deleteOrphanedRevisions.inc new file mode 100644 index 0000000000..6678d5b8b1 --- /dev/null +++ b/maintenance/deleteOrphanedRevisions.inc @@ -0,0 +1,32 @@ + + */ + +/** + * Delete one or more revisions from the database + * Do this inside a transaction + * + * @param $id Array of revision id values + * @param $db Database class (needs to be a master) + */ +function deleteRevisions( $id, &$dbw ) { + if( !is_array( $id ) ) + $id = array( $id ); + $dbw->delete( 'revision', array( 'rev_id' => $id ), 'deleteRevision' ); +} + +/** + * Spit out script usage information and exit + */ +function showUsage() { + echo( "Finds revisions which refer to nonexisting pages and deletes them from the database\n" ); + echo( "USAGE: php deleteOrphanedRevisions.php [--report]\n\n" ); + echo( " --report : Prints out a count of affected revisions but doesn't delete them\n\n" ); +} + diff --git a/maintenance/deleteOrphanedRevisions.inc.php b/maintenance/deleteOrphanedRevisions.inc.php deleted file mode 100644 index 6678d5b8b1..0000000000 --- a/maintenance/deleteOrphanedRevisions.inc.php +++ /dev/null @@ -1,32 +0,0 @@ - - */ - -/** - * Delete one or more revisions from the database - * Do this inside a transaction - * - * @param $id Array of revision id values - * @param $db Database class (needs to be a master) - */ -function deleteRevisions( $id, &$dbw ) { - if( !is_array( $id ) ) - $id = array( $id ); - $dbw->delete( 'revision', array( 'rev_id' => $id ), 'deleteRevision' ); -} - -/** - * Spit out script usage information and exit - */ -function showUsage() { - echo( "Finds revisions which refer to nonexisting pages and deletes them from the database\n" ); - echo( "USAGE: php deleteOrphanedRevisions.php [--report]\n\n" ); - echo( " --report : Prints out a count of affected revisions but doesn't delete them\n\n" ); -} - diff --git a/maintenance/deleteOrphanedRevisions.php b/maintenance/deleteOrphanedRevisions.php index f440cd7d9f..0a22515a44 100644 --- a/maintenance/deleteOrphanedRevisions.php +++ b/maintenance/deleteOrphanedRevisions.php @@ -12,7 +12,7 @@ $options = array( 'report', 'help' ); require_once( 'commandLine.inc' ); -require_once( 'deleteOrphanedRevisions.inc.php' ); +require_once( 'deleteOrphanedRevisions.inc' ); echo( "Delete Orphaned Revisions\n" ); if( isset( $options['help'] ) ) { diff --git a/maintenance/importImages.inc b/maintenance/importImages.inc new file mode 100644 index 0000000000..290f3c0794 --- /dev/null +++ b/maintenance/importImages.inc @@ -0,0 +1,88 @@ + + */ + +/** + * Search a directory for files with one of a set of extensions + * + * @param $dir Path to directory to search + * @param $exts Array of extensions to search for + * @return mixed Array of filenames on success, or false on failure + */ +function findFiles( $dir, $exts ) { + if( is_dir( $dir ) ) { + if( $dhl = opendir( $dir ) ) { + while( ( $file = readdir( $dhl ) ) !== false ) { + if( is_file( $dir . '/' . $file ) ) { + list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file ); + if( array_search( strtolower( $ext ), $exts ) !== false ) + $files[] = $dir . '/' . $file; + } + } + return $files; + } else { + return false; + } + } else { + return false; + } +} + +/** + * Split a filename into filename and extension + * + * @param $filename Filename + * @return array + */ +function splitFilename( $filename ) { + $parts = explode( '.', $filename ); + $ext = $parts[ count( $parts ) - 1 ]; + unset( $parts[ count( $parts ) - 1 ] ); + $fname = implode( '.', $parts ); + return array( $fname, $ext ); +} + +/** + * Find an auxilliary file with the given extension, matching + * the give base file path. $maxStrip determines how many extensions + * may be stripped from the original file name before appending the + * new extension. For example, with $maxStrip = 1 (the default), + * file files acme.foo.bar.txt and acme.foo.txt would be auxilliary + * files for acme.foo.bar and the extension ".txt". With $maxStrip = 2, + * acme.txt would also be acceptable. + * + * @param $file base path + * @param $auxExtension the extension to be appended to the base path + * @param $maxStrip the maximum number of extensions to strip from the base path (default: 1) + * @return string or false + */ +function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { + if ( strpos( $auxExtension, '.' ) !== 0 ) { + $auxExtension = '.' . $auxExtension; + } + + $d = dirname( $file ); + $n = basename( $file ); + + while ( $maxStrip >= 0 ) { + $f = $d . '/' . $n . $auxExtension; + + if ( file_exists( $f ) ) { + return $f; + } + + $idx = strrpos( $n, '.' ); + if ( !$idx ) break; + + $n = substr( $n, 0, $idx ); + $maxStrip -= 1; + } + + return false; +} \ No newline at end of file diff --git a/maintenance/importImages.inc.php b/maintenance/importImages.inc.php deleted file mode 100644 index 290f3c0794..0000000000 --- a/maintenance/importImages.inc.php +++ /dev/null @@ -1,88 +0,0 @@ - - */ - -/** - * Search a directory for files with one of a set of extensions - * - * @param $dir Path to directory to search - * @param $exts Array of extensions to search for - * @return mixed Array of filenames on success, or false on failure - */ -function findFiles( $dir, $exts ) { - if( is_dir( $dir ) ) { - if( $dhl = opendir( $dir ) ) { - while( ( $file = readdir( $dhl ) ) !== false ) { - if( is_file( $dir . '/' . $file ) ) { - list( /* $name */, $ext ) = splitFilename( $dir . '/' . $file ); - if( array_search( strtolower( $ext ), $exts ) !== false ) - $files[] = $dir . '/' . $file; - } - } - return $files; - } else { - return false; - } - } else { - return false; - } -} - -/** - * Split a filename into filename and extension - * - * @param $filename Filename - * @return array - */ -function splitFilename( $filename ) { - $parts = explode( '.', $filename ); - $ext = $parts[ count( $parts ) - 1 ]; - unset( $parts[ count( $parts ) - 1 ] ); - $fname = implode( '.', $parts ); - return array( $fname, $ext ); -} - -/** - * Find an auxilliary file with the given extension, matching - * the give base file path. $maxStrip determines how many extensions - * may be stripped from the original file name before appending the - * new extension. For example, with $maxStrip = 1 (the default), - * file files acme.foo.bar.txt and acme.foo.txt would be auxilliary - * files for acme.foo.bar and the extension ".txt". With $maxStrip = 2, - * acme.txt would also be acceptable. - * - * @param $file base path - * @param $auxExtension the extension to be appended to the base path - * @param $maxStrip the maximum number of extensions to strip from the base path (default: 1) - * @return string or false - */ -function findAuxFile( $file, $auxExtension, $maxStrip = 1 ) { - if ( strpos( $auxExtension, '.' ) !== 0 ) { - $auxExtension = '.' . $auxExtension; - } - - $d = dirname( $file ); - $n = basename( $file ); - - while ( $maxStrip >= 0 ) { - $f = $d . '/' . $n . $auxExtension; - - if ( file_exists( $f ) ) { - return $f; - } - - $idx = strrpos( $n, '.' ); - if ( !$idx ) break; - - $n = substr( $n, 0, $idx ); - $maxStrip -= 1; - } - - return false; -} \ No newline at end of file diff --git a/maintenance/importImages.php b/maintenance/importImages.php index 727af3cd8c..5efd1fcbb5 100644 --- a/maintenance/importImages.php +++ b/maintenance/importImages.php @@ -11,7 +11,7 @@ $optionsWithArgs = array( 'extensions', 'comment', 'comment-file', 'comment-ext', 'user', 'license' ); require_once( 'commandLine.inc' ); -require_once( 'importImages.inc.php' ); +require_once( 'importImages.inc' ); $added = $skipped = $overwritten = 0; echo( "Import Images\n\n" ); diff --git a/maintenance/reassignEdits.inc b/maintenance/reassignEdits.inc new file mode 100644 index 0000000000..e68b4cf512 --- /dev/null +++ b/maintenance/reassignEdits.inc @@ -0,0 +1,143 @@ + + * @licence GNU General Public Licence 2.0 or later + */ + +/** + * Reassign edits from one user to another + * + * @param $from User to take edits from + * @param $to User to assign edits to + * @param $rc Update the recent changes table + * @param $report Don't change things; just echo numbers + * @return integer Number of entries changed, or that would be changed + */ +function reassignEdits( &$from, &$to, $rc = false, $report = false ) { + $dbw = wfGetDB( DB_MASTER ); + $dbw->immediateBegin(); + $fname = 'reassignEdits'; + + # Count things + out( "Checking current edits..." ); + $res = $dbw->select( 'revision', 'COUNT(*) AS count', userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); + $row = $dbw->fetchObject( $res ); + $cur = $row->count; + out( "found {$cur}.\n" ); + + out( "Checking deleted edits..." ); + $res = $dbw->select( 'archive', 'COUNT(*) AS count', userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); + $row = $dbw->fetchObject( $res ); + $del = $row->count; + out( "found {$del}.\n" ); + + # Don't count recent changes if we're not supposed to + if( $rc ) { + out( "Checking recent changes..." ); + $res = $dbw->select( 'recentchanges', 'COUNT(*) AS count', userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); + $row = $dbw->fetchObject( $res ); + $rec = $row->count; + out( "found {$rec}.\n" ); + } else { + $rec = 0; + } + + $total = $cur + $del + $rec; + out( "\nTotal entries to change: {$total}\n" ); + + if( !$report ) { + if( $total ) { + # Reassign edits + out( "\nReassigning current edits..." ); + $res = $dbw->update( 'revision', userSpecification( $to, 'rev_user', 'rev_user_text' ), userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); + out( "done.\nReassigning deleted edits..." ); + $res = $dbw->update( 'archive', userSpecification( $to, 'ar_user', 'ar_user_text' ), userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); + out( "done.\n" ); + # Update recent changes if required + if( $rc ) { + out( "Updating recent changes..." ); + $res = $dbw->update( 'recentchanges', userSpecification( $to, 'rc_user', 'rc_user_text' ), userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); + out( "done.\n" ); + } + } + } + + $dbw->immediateCommit(); + return (int)$total; +} + +/** + * Return the most efficient set of user conditions + * i.e. a user => id mapping, or a user_text => text mapping + * + * @param $user User for the condition + * @param $idfield Field name containing the identifier + * @param $utfield Field name containing the user text + * @return array + */ +function userConditions( &$user, $idfield, $utfield ) { + return $user->getId() ? array( $idfield => $user->getId() ) : array( $utfield => $user->getName() ); +} + +/** + * Return user specifications + * i.e. user => id, user_text => text + * + * @param $user User for the spec + * @param $idfield Field name containing the identifier + * @param $utfield Field name containing the user text + * @return array + */ +function userSpecification( &$user, $idfield, $utfield ) { + return array( $idfield => $user->getId(), $utfield => $user->getName() ); +} + +/** + * Echo output if $wgSilent is off + * + * @param $output Output to echo + * @return bool True if the output was echoed + */ +function out( $output ) { + global $wgSilent; + if( !$wgSilent ) { + echo( $output ); + return true; + } else { + return false; + } +} + +/** + * Mutator for $wgSilent + * + * @param $silent Switch on $wgSilent + */ +function silent( $silent = true ) { + global $wgSilent; + $wgSilent = $silent; +} + +/** + * Initialise the user object + * + * @param $username Username or IP address + * @return User + */ +function initialiseUser( $username ) { + if( User::isIP( $username ) ) { + $user = new User(); + $user->setId( 0 ); + $user->setName( $username ); + } else { + $user = User::newFromName( $username ); + } + $user->load(); + return $user; +} + diff --git a/maintenance/reassignEdits.inc.php b/maintenance/reassignEdits.inc.php deleted file mode 100644 index e68b4cf512..0000000000 --- a/maintenance/reassignEdits.inc.php +++ /dev/null @@ -1,143 +0,0 @@ - - * @licence GNU General Public Licence 2.0 or later - */ - -/** - * Reassign edits from one user to another - * - * @param $from User to take edits from - * @param $to User to assign edits to - * @param $rc Update the recent changes table - * @param $report Don't change things; just echo numbers - * @return integer Number of entries changed, or that would be changed - */ -function reassignEdits( &$from, &$to, $rc = false, $report = false ) { - $dbw = wfGetDB( DB_MASTER ); - $dbw->immediateBegin(); - $fname = 'reassignEdits'; - - # Count things - out( "Checking current edits..." ); - $res = $dbw->select( 'revision', 'COUNT(*) AS count', userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); - $row = $dbw->fetchObject( $res ); - $cur = $row->count; - out( "found {$cur}.\n" ); - - out( "Checking deleted edits..." ); - $res = $dbw->select( 'archive', 'COUNT(*) AS count', userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); - $row = $dbw->fetchObject( $res ); - $del = $row->count; - out( "found {$del}.\n" ); - - # Don't count recent changes if we're not supposed to - if( $rc ) { - out( "Checking recent changes..." ); - $res = $dbw->select( 'recentchanges', 'COUNT(*) AS count', userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); - $row = $dbw->fetchObject( $res ); - $rec = $row->count; - out( "found {$rec}.\n" ); - } else { - $rec = 0; - } - - $total = $cur + $del + $rec; - out( "\nTotal entries to change: {$total}\n" ); - - if( !$report ) { - if( $total ) { - # Reassign edits - out( "\nReassigning current edits..." ); - $res = $dbw->update( 'revision', userSpecification( $to, 'rev_user', 'rev_user_text' ), userConditions( $from, 'rev_user', 'rev_user_text' ), $fname ); - out( "done.\nReassigning deleted edits..." ); - $res = $dbw->update( 'archive', userSpecification( $to, 'ar_user', 'ar_user_text' ), userConditions( $from, 'ar_user', 'ar_user_text' ), $fname ); - out( "done.\n" ); - # Update recent changes if required - if( $rc ) { - out( "Updating recent changes..." ); - $res = $dbw->update( 'recentchanges', userSpecification( $to, 'rc_user', 'rc_user_text' ), userConditions( $from, 'rc_user', 'rc_user_text' ), $fname ); - out( "done.\n" ); - } - } - } - - $dbw->immediateCommit(); - return (int)$total; -} - -/** - * Return the most efficient set of user conditions - * i.e. a user => id mapping, or a user_text => text mapping - * - * @param $user User for the condition - * @param $idfield Field name containing the identifier - * @param $utfield Field name containing the user text - * @return array - */ -function userConditions( &$user, $idfield, $utfield ) { - return $user->getId() ? array( $idfield => $user->getId() ) : array( $utfield => $user->getName() ); -} - -/** - * Return user specifications - * i.e. user => id, user_text => text - * - * @param $user User for the spec - * @param $idfield Field name containing the identifier - * @param $utfield Field name containing the user text - * @return array - */ -function userSpecification( &$user, $idfield, $utfield ) { - return array( $idfield => $user->getId(), $utfield => $user->getName() ); -} - -/** - * Echo output if $wgSilent is off - * - * @param $output Output to echo - * @return bool True if the output was echoed - */ -function out( $output ) { - global $wgSilent; - if( !$wgSilent ) { - echo( $output ); - return true; - } else { - return false; - } -} - -/** - * Mutator for $wgSilent - * - * @param $silent Switch on $wgSilent - */ -function silent( $silent = true ) { - global $wgSilent; - $wgSilent = $silent; -} - -/** - * Initialise the user object - * - * @param $username Username or IP address - * @return User - */ -function initialiseUser( $username ) { - if( User::isIP( $username ) ) { - $user = new User(); - $user->setId( 0 ); - $user->setName( $username ); - } else { - $user = User::newFromName( $username ); - } - $user->load(); - return $user; -} - diff --git a/maintenance/reassignEdits.php b/maintenance/reassignEdits.php index 0d64020280..5825644e80 100644 --- a/maintenance/reassignEdits.php +++ b/maintenance/reassignEdits.php @@ -11,7 +11,7 @@ $options = array( 'force', 'norc', 'quiet', 'report' ); require_once( 'commandLine.inc' ); -require_once( 'reassignEdits.inc.php' ); +require_once( 'reassignEdits.inc' ); # Set silent mode; --report overrides --quiet if( !@$options['report'] && @$options['quiet'] ) diff --git a/maintenance/updateArticleCount.inc b/maintenance/updateArticleCount.inc new file mode 100644 index 0000000000..a847a2edb1 --- /dev/null +++ b/maintenance/updateArticleCount.inc @@ -0,0 +1,61 @@ + + */ + +class ArticleCounter { + + var $dbr; + var $namespaces; + + function ArticleCounter() { + global $wgContentNamespaces; + $this->namespaces = $wgContentNamespaces; + $this->dbr = wfGetDB( DB_SLAVE ); + } + + /** + * Produce a comma-delimited set of namespaces + * Includes paranoia + * + * @return string + */ + function makeNsSet() { + foreach( $this->namespaces as $namespace ) + $namespaces[] = intval( $namespace ); + return implode( ', ', $namespaces ); + } + + /** + * Produce SQL for the query + * + * @return string + */ + function makeSql() { + list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' ); + $nsset = $this->makeNsSet(); + return "SELECT COUNT(DISTINCT page_namespace, page_title) AS pagecount " . + "FROM $page, $pagelinks " . + "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " . + "AND page_is_redirect = 0 AND page_len > 0"; + } + + /** + * Count the number of valid content pages in the wiki + * + * @return mixed Integer, or false if there's a problem + */ + function count() { + $res = $this->dbr->query( $this->makeSql(), __METHOD__ ); + $row = $this->dbr->fetchObject( $res ); + $this->dbr->freeResult( $res ); + return $row->pagecount; + } + +} + + diff --git a/maintenance/updateArticleCount.inc.php b/maintenance/updateArticleCount.inc.php deleted file mode 100644 index a847a2edb1..0000000000 --- a/maintenance/updateArticleCount.inc.php +++ /dev/null @@ -1,61 +0,0 @@ - - */ - -class ArticleCounter { - - var $dbr; - var $namespaces; - - function ArticleCounter() { - global $wgContentNamespaces; - $this->namespaces = $wgContentNamespaces; - $this->dbr = wfGetDB( DB_SLAVE ); - } - - /** - * Produce a comma-delimited set of namespaces - * Includes paranoia - * - * @return string - */ - function makeNsSet() { - foreach( $this->namespaces as $namespace ) - $namespaces[] = intval( $namespace ); - return implode( ', ', $namespaces ); - } - - /** - * Produce SQL for the query - * - * @return string - */ - function makeSql() { - list( $page, $pagelinks ) = $this->dbr->tableNamesN( 'page', 'pagelinks' ); - $nsset = $this->makeNsSet(); - return "SELECT COUNT(DISTINCT page_namespace, page_title) AS pagecount " . - "FROM $page, $pagelinks " . - "WHERE pl_from=page_id and page_namespace IN ( $nsset ) " . - "AND page_is_redirect = 0 AND page_len > 0"; - } - - /** - * Count the number of valid content pages in the wiki - * - * @return mixed Integer, or false if there's a problem - */ - function count() { - $res = $this->dbr->query( $this->makeSql(), __METHOD__ ); - $row = $this->dbr->fetchObject( $res ); - $this->dbr->freeResult( $res ); - return $row->pagecount; - } - -} - - diff --git a/maintenance/updateArticleCount.php b/maintenance/updateArticleCount.php index a24984a86a..15033ad309 100644 --- a/maintenance/updateArticleCount.php +++ b/maintenance/updateArticleCount.php @@ -10,7 +10,7 @@ $options = array( 'update', 'help' ); require_once( 'commandLine.inc' ); -require_once( 'updateArticleCount.inc.php' ); +require_once( 'updateArticleCount.inc' ); echo( "Update Article Count\n\n" ); if( isset( $options['help'] ) && $options['help'] ) {